#ifndef PATCH_H
#define PATCH_H

namespace A48 {

class Patch {
  FaceContainer fpc_;
  PatchContainer adjpc_;

  friend class Mesh;

  int camera_index;

  float box3DMinX;
  float box3DMinY;
  float box3DMinZ;
  float box3DMaxX;
  float box3DMaxY;
  float box3DMaxZ;

  float box2DImgMinX;
  float box2DImgMinY;
  float box2DImgMaxX;
  float box2DImgMaxY;

  float box2DTextMinX;
  float box2DTextMinY;
  float box2DTextMaxX;
  float box2DTextMaxY;

  int index;

 public:
  Patch();
  ~Patch();
  PatchIter adj_patches_begin() { return adjpc_.begin(); };
  PatchIter adj_patches_end() { return adjpc_.end(); };
  int num_adj_patches() { return adjpc_.size(); };

  FaceIter faces_patch_begin() { return fpc_.begin(); };
  FaceIter faces_patch_end() { return fpc_.end(); };
  int num_faces_patch() { return fpc_.size(); };

  void set_index(int indx) {index = indx;};
  int get_index() { return index;};

  void set_camera_index(int indx) {camera_index = indx;};
  int get_camera_index() { return camera_index;};

  void set_box2DImgMinX(float value) {box2DImgMinX = value;};
  float get_box2DImgMinX() { return box2DImgMinX;};
  void set_box2DImgMinY(float value) {box2DImgMinY = value;};
  float get_box2DImgMinY() { return box2DImgMinY;};
  void set_box2DImgMaxX(float value) {box2DImgMaxX = value;};
  float get_box2DImgMaxX() { return box2DImgMaxX;};
  void set_box2DImgMaxY(float value) {box2DImgMaxY = value;};
  float get_box2DImgMaxY() { return box2DImgMaxY;};

  void set_box2DTextMinX(float value) {box2DTextMinX = value;};
  float get_box2DTextMinX() { return box2DTextMinX;};
  void set_box2DTextMinY(float value) {box2DTextMinY = value;};
  float get_box2DTextMinY() { return box2DTextMinY;};
  void set_box2DTextMaxX(float value) {box2DTextMaxX = value;};
  float get_box2DTextMaxX() { return box2DTextMaxX;};
  void set_box2DTextMaxY(float value) {box2DTextMaxY = value;};
  float get_box2DTextMaxY() { return box2DTextMaxY;};

  void set_box3DMinX(float value) {box3DMinX = value;};
  float get_box3DMinX() { return box3DMinX;};
  void set_box3DMinY(float value) {box3DMinY = value;};
  float get_box3DMinY() { return box3DMinY;};
  void set_box3DMinZ(float value) {box3DMinZ = value;};
  float get_box3DMinZ() { return box3DMinZ;};
  void set_box3DMaxX(float value) {box3DMaxX = value;};
  float get_box3DMaxX() { return box3DMaxX;};
  void set_box3DMaxY(float value) {box3DMaxY = value;};
  float get_box3DMaxY() { return box3DMaxY;};
  void set_box3DMaxZ(float value) {box3DMaxZ = value;};
  float get_box3DMaxZ() { return box3DMaxZ;};

  bool add_adj_patch(Patch* p) 
    { std::pair<PatchIter, bool> r = adjpc_.insert(p); return r.second;};

  void del_adj_patch(Patch* p) {
    adjpc_.erase(p); 
    delete(p);
  }

  bool add_face_patch(Face* f) 
    { std::pair<FaceIter, bool> r = fpc_.insert(f); return r.second;};

  void del_face_patch(Face* f) {
    fpc_.erase(f); 
    delete(f);
  }
};

}

#endif
